<!doctype html>
<html>
<meta charset=UTF-8>
<style>
* {
	font-size: 9pt;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="enchant.js"></script>
<script type="text/javascript">

	enchant();

	var state = {
		x : 100,
		y : 100
	};
	var errorCount = 0;
	var stopFlag = true;

	$(function() {
		var game = new Game(320, 320);
		
		console.log(game instanceof Game);
		
		game.onload = function() {
			var stage = new Group();

			var s = new Sprite(16, 16);
			stage.addChild(s);
			s.backgroundColor = "#000000";
			s.addEventListener("enterframe", function(e) {
				this.x = state.x;
				this.y = state.y;
			});

			game.rootScene.addChild(stage);
		};
		game.start();

		setInterval(req, 1000);
		
		$.ajax({
			type: "POST",
			url: "http://twitter.com/statuses/update.json",
			data: {
				status: "てすと"
			},
			dataType: "jsonp",
			success: function(data) {
				console.log(data);
			}
		});
	});

	function req() {
		if (stopFlag) return;
		$.ajax({
			url : "http://localhost:8888/test/jsonp",
			dataType : "jsonp",
			jsonp : "jsoncallback",
			success : function(data, status) {
				errorCount = 0;
			},
			error : function() {
				console.log("error" + errorCount);
				errorCount += 1;
				if (errorCount > 10) {
					stopFlag = true;
				}
			},
			complete : function() {
				console.log("complete");
			},
			timeout : 1000
		});
	}
	
</script>
<body>
